package com.tsd.core.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tsd.core.vo.HlpException;

/**
 * Json工具类
 * @author Hillpool
 */
public class JsonUtil {
    /**
     * 将fastjson的JSON.parseObject进行封装，解释失败时返回null
     *
     * @param json
     * @return
     * @throws HlpException
     */
    public static JSONObject parseObject(String json) throws HlpException {
        try {
            return JSON.parseObject(json);
        } catch (Exception e) {
            throw new HlpException("json格式不对：" + e.getMessage());
        }
    }
}
